package cn.iocoder.yudao.module.shop.footprint.controller.app;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.shop.footprint.service.AppShopFootprintService;
import cn.iocoder.yudao.module.shop.footprint.vo.AppShopFootprintVO;
import cn.iocoder.yudao.module.shop.info.vo.AppShopPrimaryReqVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;

/**
 * <pre>
 * OOoO0OOoO0OOOooo0oOOOO0OOOOO0oooOO0ooOOO0Ooooo0OOOOo0ooooO0OOooo0Ooooo0OOOOO
 *  这里是文件说明
 * OOoO0OOoO0OOOooo0oOOOO0OOOOO0oooOO0ooOOO0Ooooo0OOOOo0ooooO0OOooo0Ooooo0OOOOO
 * </pre>
 *
 * @author 山野羡民（1032694760@qq.com）
 * @since 2025/01/10
 */
@Tag(name = "用户 App - 店铺浏览记录")
@RestController
@RequestMapping("/shop/footprint")
@Validated
public class AppShopFootprintController {
    @Resource
    private AppShopFootprintService appShopFootprintService;

    @PostMapping("/save")
    @Operation(summary = "浏览店铺")
    public CommonResult<Boolean> save(@Valid @RequestBody AppShopPrimaryReqVO reqVO) {
        return success(appShopFootprintService.save(reqVO.getShopId(), getLoginUserId()));
    }

    @PostMapping("/delete")
    @Operation(summary = "删除店铺浏览记录")
    public CommonResult<Boolean> delete(@Valid @RequestBody AppShopPrimaryReqVO reqVO) {
        return success(appShopFootprintService.delete(reqVO.getShopId(), getLoginUserId()));
    }

    @PostMapping("/clear")
    @Operation(summary = "清除店铺浏览记录")
    public CommonResult<Boolean> clear() {
        return success(appShopFootprintService.clear(getLoginUserId()));
    }

    @GetMapping("/page")
    @Operation(summary = "获得店铺浏览记录分页")
    public CommonResult<PageResult<AppShopFootprintVO>> page(@Valid PageParam reqVO) {
        return success(appShopFootprintService.getPage(reqVO.getPageNo(), reqVO.getPageSize(), getLoginUserId()));
    }

}
